//
//  BRCarStyleCell.m
//  carcareIOS
//
//  Created by 王然 on 16/8/3.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "BRCarStyleCell.h"

#define CELL_BIG_HEIGHT (76)

#define Word_Color (COLOR_HEXSTRING(@"#424242"))

#define Word_Wrong_Color (COLOR_HEXSTRING(@"#fd6500"))

@interface BRCarStyleCell()

@property (nonatomic , strong) UIImageView * iconImageV;

@property (nonatomic , strong) UILabel * carTitleL;

@end
@implementation BRCarStyleCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createUI];
        [self resetBorderWidth:0.5 borderColor:[Theme lineColor]];
    }
    return self;
}
- (void)createUI
{
    CGFloat iconX = 9 * __MAIN_RATIO_375;
    UIImage * icon = ImageNamed(@"BRCarStyleNormalImage");
    CGFloat iconImageVW = 107 * __MAIN_RATIO_375 ;
    CGFloat iconImageVH = iconImageVW * icon.size.height / icon.size.width;
    self.iconImageV = [[UIImageView imageViewWithFrame:CGRectMake(iconX, (CELL_BIG_HEIGHT - iconImageVH) / 2, iconImageVW, iconImageVH) image:icon] setupOnView:self];
    
    UIImage * rightImage = ImageNamed(@"cell_right");
    
    [Factory imageViewWithCenter: CGPointMake(__MAIN_WIDTH - 25, CELL_BIG_HEIGHT / 2) image:rightImage onView:self];
    CGFloat labelX = self.iconImageV.right + 10 * __MAIN_RATIO_375;
    CGFloat lableW = __MAIN_WIDTH - labelX - (rightImage.size.width + 25);
//    CGFloat labelY = self.iconImageV.top ;
    self.carTitleL = [[[UILabel labelWithFrame:CGRectMake(labelX, 0, lableW, CELL_BIG_HEIGHT) font:FONT_DEFAULT_Light(15) text:@"请选择车型" textColor:COLOR_HEXSTRING(@"#bdbdbd")] setupOnView:self] labelResetTextAlignment:NSTextAlignmentRight];
    self.carTitleL.backgroundColor = [UIColor clearColor];
    
    self.carTitleL.numberOfLines = 2;
}
- (void)reloadIconImageUrl:(NSString *)imageUrl title:(NSString *)title
{
    if (![imageUrl isKindOfClass:[NSNull class]] && [imageUrl isNotNil]) {
        [self.iconImageV setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:ImageNamed(@"BRCarStyleNormalImage")];
        self.iconImageV.height = self.iconImageV.width * self.iconImageV.image.size.height / self.iconImageV.image.size.width;
        self.iconImageV.top = (CELL_BIG_HEIGHT - self.iconImageV.height) / 2;
    }
    if ([title isNotNil]) {
        self.carTitleL.textColor = COLOR_HEXSTRING(@"#424242");
        self.carTitleL.text = title;
    }
   
}
//重置控件错误颜色  错误传入YES 否则传入NO
- (void)reloadTextColorIsWrong:(BOOL)isWrong
{
    [self.carTitleL setTextColor:(isWrong ? Word_Wrong_Color : Word_Color)];
}
+ (CGFloat)getCellHeight
{
    return CELL_BIG_HEIGHT;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
